import React, { Suspense, lazy } from 'react'

import { BrowserRouter as Router, HashRouter as Hash, Route, Switch, Redirect } from "react-router-dom"
import Loading from '../components/Loading'
// import Demo from './demo/demo'
// import NotFound from './errorpages/404'
// import BadServices from './errorpages/503'
import { Modal } from "antd"
export default function MainView() {
    return (
        <Router>
            <Route render={MainLayout}></Route>
        </Router>
    )
}


function MainLayout(props: any) {
    return (
        <div className='page'>
            <Suspense fallback={Loading}>
                <Switch>
                    <Route path="/" exact render={() => (<Redirect to="/login" />)}></Route>

                    <Route path="/login" component={lazy(() => import('./logins/login'))}></Route>
                    <Route path="/register" component={lazy(() => import('./logins/Register'))}></Route>
                    <Route path="/forgetpass" component={lazy(() => import('./logins/ForgetPass'))}></Route>
                    <Route path="/main" component={lazy(() => import("./main/index"))}></Route>

                    <Route path="/404" component={lazy(() => import('./errorpages/404'))}></Route>
                    <Route path="/503" component={lazy(() => import('./errorpages/503'))}></Route>
                    <Route path="/demo" render={lazy(() => import('./demo/demo'))}></Route>
                    <Route render={() => (<Redirect to="/404" />)}>

                    </Route>
                </Switch>
            </Suspense>
            <Modal
                title="Modal"
                visible={props.show}
                okText="确认"
            >
                <h2>token校验失败,请重新登录.</h2>
            </Modal>

        </div >
    )
}